package com.mjk.common.core.jdbc.datasource;

import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

public class DynamicDataSource extends AbstractRoutingDataSource {
    private static final ThreadLocal<String> contextHolder = new ThreadLocal<>();

    public static void setDatabaseType(String type) {
        contextHolder.set(type);
    }

    public static String getDatabaseType() {      
        return contextHolder.get();
    }

    @Override
    protected Object determineCurrentLookupKey() {    	
        return contextHolder.get();
    }
    
}
